﻿using System;
using System.Text;

namespace dotHTML.HTML {
    /// <summary>
    /// Represents a progress bar.
    /// </summary>
    [Serializable]
    public class Progress : Element {
        private Form _form;
        private float? _max;
        private float? _value;

        /// <summary>
        /// Determines the parent form of this progress bar.
        /// </summary>
        public Form Form {
            get { return _form; }
            set { _form = value; }
        }

        /// <summary>
        /// Determines the maximum value of the progress bar.
        /// </summary>
        public float? Max {
            get { return _max; }
            set { _max = value; }
        }

        /// <summary>
        /// Determines the current value of the progress bar.
        /// </summary>
        public float? Value {
            get { return _value; }
            set { _value = value; }
        }

        /// <summary>
        /// Gets a formatted string of all child elements of this element.
        /// </summary>
        /// <param name="sb">The StringBuilder to write this element's child
        /// data to.</param>
        protected override void WriteLocalAttributes(StringBuilder sb) {
            if (_form != null) {
                AttributeWriter.Write(sb, _form.ID, "form");
            }
            AttributeWriter.Write(sb, _max, "max");
            AttributeWriter.Write(sb, _value, "value");
        }
    }
}
